#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    string s;
    for(auto& t : a) {
        int x;
        cin >> x;
        cin >> s;
        for(auto ch : s) {
            if(ch == 'U') {
                t--;
            }else{
                t++;
            }
            if(t == 10) t = 0;
            if(t == -1) t = 9;
        }
    }
    for(auto x : a) cout << x << ' ';
    cout << endl;
}

signed main() {
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}